package com.furschina.dao;

import org.springframework.stereotype.Repository;

import cn.wooshai.core.dao.hibernate.GenericHibernateDao;

import com.furschina.model.Article;
import com.furschina.model.ArticleRecord;

@Repository
public class ArticleRecordDao extends GenericHibernateDao<ArticleRecord> {
	
	public ArticleRecord getRecordByArticle(Article article){
		String sql = "from ArticleRecord as ar where ar.article = ? ";
		return this.findOne(sql, true, article);
	}
	
	public void incrViews(Long id) {
		this.bulkUpdate("update ArticleRecord set views=views+1 where article.id=?", id);
	}
	
	public void incrDiggs(Long id) {
		this.bulkUpdate("update ArticleRecord set diggs=diggs+1 where article.id=?", id);
	}
	
	public void incrBuries(Long id) {
		this.bulkUpdate("update ArticleRecord set buries=buries+1 where article.id=?", id);
	}
}